<%@ page import="java.sql.Connection" %>
<%@ page import="java.sql.PreparedStatement" %>
<%@ page import="java.sql.ResultSet" %>
<%@ page import="java.sql.DriverManager" %><%--
  Created by IntelliJ IDEA.
  User: LENOVO
  Date: 2020/8/20
  Time: 14:47
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":"
            + request.getServerPort() +path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>供应商商品列表</title>
    <link type="text/css" rel="stylesheet" href="/css/query.css">
</head>
<body>
<div><h3>设备列表</h3></div>
<%!
   public static final String DBDriver="com.mysql.jdbc.Driver";
   public static final String DBUrl="jdbc:mysql://localhost:3306/invoicing_system";
   public static final String DBUserName="root";
   public static final String DBPwd="root";
%>
${sessionScope.SloginedName}
<%
    Connection conn=null;
    PreparedStatement ps=null;
    ResultSet rs=null;
    Class.forName(DBDriver);
    String suppName=(String)request.getSession().getAttribute("SloginedName");
    conn= DriverManager.getConnection(DBUrl,DBUserName,DBPwd);
    String sql="select equipment.eid,e_name,num,price from production,supplier,equipment where production.sid=supplier.sid AND production.eid=equipment.eid AND supplier.sid='"+suppName+"'";
    ps=conn.prepareStatement(sql);
    rs=ps.executeQuery();
%>

<div class="dv2" align="center">
    <table class="table">
        <tr style="background-color: silver ; height: 60px;color: #ffffff">
            <td width="25%">设备名称</td>
            <td width="25%">库存</td>
            <td width="25%">单价</td>
            <td>编辑</td>
        </tr>
        <%
            int num=1;
            while(rs.next()){
                if(num%2!=0){
        %>
        <tr>
            <td style="height: 60px;">
                <%=rs.getString("e_name")%>
            </td>
            <td>
                <%=rs.getString("num")%>
            </td>
            <td>
                <%=rs.getString("price")%>
            </td>
            <td>
                <a class="lik" href="mysqlupdate.jsp?eid=<%=rs.getString("eid")%>">update</a><a class="lik" href="mysqldelete.jsp">delete</a>
            </td>
        </tr>
        <%
            }else{
        %>
        <tr style="background-color: #ffcccc;height: 60px;">
            <td style="height: 60px;">
                <%=rs.getString("s_name")%>
            </td>
            <td>
                <%=rs.getString("num")%>
            </td>
            <td>
                <%=rs.getString("price")%>
            </td>
            <td>
                <a class="lik" href="mysqlupdate.jsp?">update</a><a class="lik" href="mysqldelete.jsp">delete</a>
            </td>
        </tr>
        <%
            }
                num++;
            }
        %>
    </table>
    <br>
    <br>
    <div class="lik2"><a class="table" href="mysqlinsert.jsp">添加设备机械</a></div>
</div>
<%
    rs.close();
    ps.close();
    conn.close();
%>
</body>
</html>
